package com.link2room.soundwave.controller.manager;

import com.link2room.common.dto.param.base.BaseL2rParamDto;
import com.link2room.common.dto.result.base.BaseResultDto;
import com.link2room.sideswipe.permissionResouces.annotation.L2RPermissionResources;
import com.link2room.soundwave.dto.param.manager.L2RPMSCouponTypeManagerParamDto;
import com.link2room.soundwave.dto.result.base.L2RPmsCouponTypeDto;
import com.link2room.soundwave.facade.IL2RPMSCouponTypeFacadeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import static com.link2room.soundwave.constant.PermissionConstant.*;

/**
 * @author sqj88
 * @date 2018/1/4 17:14
 */
@Api(tags = "联房-PMS电子券类型对照")
@RestController
@RequestMapping("/manager/L2RPMSCouponTypes")
public class L2RPMSCouponTypeManagerController {
    @Resource
    private IL2RPMSCouponTypeFacadeService l2RPMSCouponTypeFacadeService;

    @ApiOperation(value ="获取联房PMS电子券类型对照列表")
    @RequestMapping(method = RequestMethod.GET)
    @L2RPermissionResources(value = L2RPMSCouponTypeMappingList,name = "获取联房PMS电子券类型对照列表")
    public BaseResultDto<L2RPmsCouponTypeDto> listL2RPMSCouponTypeMappingList(
    ) throws Exception{
        BaseL2rParamDto baseL2rParamDto=new BaseL2rParamDto();
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        baseResultDto.setQueryResult(l2RPMSCouponTypeFacadeService.listL2RPMSCouponTypes(baseL2rParamDto));
        return  baseResultDto;
    }

    @ApiOperation(value ="获取联房PMS电子券类型对照详情")
    @ApiImplicitParam(name="id",value="电子券类型对照",dataType="Long", paramType = "path",example="12")
    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    @L2RPermissionResources(value = L2RPMSCouponTypeMapping,name = "获取联房PMS电子券类型对照详情")
    public BaseResultDto<L2RPmsCouponTypeDto> getL2RPMSCouponTypeMapping(
            @PathVariable Long id
    ) throws Exception{
        BaseL2rParamDto baseL2rParamDto=new BaseL2rParamDto();
        baseL2rParamDto.setId(id);
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        baseResultDto.setResultInfo(l2RPMSCouponTypeFacadeService.getL2RPMSCouponType(baseL2rParamDto));
        return  baseResultDto;
    }

    @ApiOperation(value ="保存联房PMS电子券类型对照")
    @RequestMapping(method = RequestMethod.POST)
    @L2RPermissionResources(value = newL2RPMSCouponTypeMapping,name = "保存联房PMS电子券类型对照")
    public BaseResultDto<L2RPmsCouponTypeDto> saveL2RPMSCouponTypeMapping(
            @RequestBody L2RPMSCouponTypeManagerParamDto l2RPMSCouponTypeManagerParamDto
    ) throws Exception{
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        baseResultDto.setResultInfo(l2RPMSCouponTypeFacadeService.saveL2RPMSCouponType(l2RPMSCouponTypeManagerParamDto));
        return  baseResultDto;
    }

    @ApiOperation(value ="更新联房PMS电子券类型对照")
    @RequestMapping(method = RequestMethod.PUT)
    @L2RPermissionResources(value = updateL2RPMSCouponTypeMapping,name = "更新联房PMS电子券类型对照")
    public BaseResultDto<L2RPmsCouponTypeDto> updateL2RPMSCouponTypeMapping(
            @RequestBody L2RPMSCouponTypeManagerParamDto l2RPMSCouponTypeManagerParamDto
    ) throws Exception{
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        baseResultDto.setResultInfo(l2RPMSCouponTypeFacadeService.updateL2RPMSCouponType(l2RPMSCouponTypeManagerParamDto));
        return  baseResultDto;
    }
}
